<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="icon" href="favicon.ico" type="image/x-icon"/>
<title>节点管理-权限管理-{$site.BACK_NAME}</title>
<include file="Public:jscss"/>
</head>
<body>
<div class="wrap">
 <include file="Public:head"/>
 <div class="mainBody">
  <include file="Public:left"/>
  <div id="Right">
   <div class="Item hr">
    <div class="current">节点管理</div>
   </div>
   <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
    <thead>
     <tr>
      <td width="5%">序号</td>
      <td width="25%">节点结构  <b title="单击分类隐藏/显示该分类下在子类">[i]</b></td>
      <td width="5%">节点ID</td>
      <td width="10%">名称</td>
      <td width="20%">显示名</td>
      <td width="5%">排序</td>
      <td width="10%">类型</td>
      <td width="5%">状态</td>
      <td width="15%">操作</td>
     </tr>
    </thead>
    <volist name="list" id="vo" key="k">
    <tr align="center" id="{$vo.id}" pid="{$vo.pid}">
     <td>{$k}</td>
     <td align="left" class="cfz_tree" style="cursor: pointer;">{$vo.fullname}</td>
     <td>{$vo.id}</td>
     <td align="left">{$vo.name}</td>
     <td align="left">{$vo.title}</td>
     <td edit="0" fd="sort">{$vo.sort}</td>
     <td align="left">{$level[$vo['level']]}</td>
     <td>
	 <eq name="vo.status" value="1">
	 <font color="green">启用</font>
	 <else/>
	 <font color="red">禁用</font>
	 </eq>
	 </td>
     <td>
	  [
	  <a href="javascript:void(0);" class="cfz_status" data-val="{$vo.status}">
	  <eq name="vo.status" value="1">
	  <font color="red">禁用</font>
	  <else/>
	  <font color="green">启用</font>
	  </eq>
	  </a>
	  ] 
	  [ <a href="{:U('Node/edt',array('id'=>$vo['id'],'mu'=>'User'))}" class="edit">编辑</a> ]
	  [ <a data-id="{$vo.id}" href="javascript:void(0)" name="{$vo.title}" class="cfz_del">删除 </a> ]
	 </td>
    </tr>
    </volist>
   </table>
  </div>
 </div>
</div>
<div class="clear"></div>
<include file="Public:foot"/>
<script type="text/javascript">
$(function(){
	//快捷启用禁用操作
	$(".cfz_status").click(function(){
		var obj = $(this);
		var id = $(this).parents("tr").attr("id");
		var t_status = $(this).data("val");
		$.getJSON("{:U('Node/opns')}", { id:id, status:t_status }, function(json){
			if(json.errcode == 0){
				$.jBox.success(json.errmsg, '状态已改变');
				$(obj).data("val",json.data.status).html(t_status==1?"启用":"禁用").parents("td").prev().html(t_status==1?"禁用":"启用");
			}else{
				$.jBox.alert(json.errmsg, '提示信息');
			}
		});
	});
	//快捷改变操作排序dblclick
	$("tbody>tr>td[fd]").click(function(){
		var inval = $(this).html();
		var infd = $(this).attr("fd");
		var inid =  $(this).parents("tr").attr("id");
		if($(this).attr('edit')==0){
			$(this).attr('edit','1').html("<input class='input' size='5' id='edit_"+infd+"_"+inid+"' value='"+inval+"' />").find("input").select();
		}
		$("#edit_"+infd+"_"+inid).focus().bind("blur",function(){
			var editval = $(this).val();
			$(this).parents("td").html(editval).attr('edit','0');
			if(inval!=editval){
				$.post("{:U('Node/opst')}",{id:inid,fd:infd,sort:editval});
			}
		})
	});
	//操作定义
	var chn=function(cid,op){
		if(op=="show"){
			$("tr[pid='"+cid+"']").each(function(){
				$(this).removeAttr("status").show();
				chn($(this).attr("id"),"show");
			});
		}else{
			$("tr[pid='"+cid+"']").each(function(){
				$(this).attr("status",1).hide();
				chn($(this).attr("id"),"hide");
			});
		}
	}
	//隐显树
	$(".cfz_tree").click(function(){
		if($(this).attr("status")!=1){
			chn($(this).parent().attr("id"),"hide");
			$(this).attr("status",1);
		}else{
			chn($(this).parent().attr("id"),"show");
			$(this).removeAttr("status");
		}
	});
	//删除
	$(".cfz_del").click(function(){
		var dellink = "{:U('Node/del')}";
		var deldata = { nid: $(this).data("id")};
		$.jBox.confirm(
			'您真的打算删除【<b>'+$(this).attr("name")+'</b>】节点吗?<br/>这将导致该节点无法访问。<br/>本操作仅允许超级管理员操作!',
			"温馨提示",
			function(v, h, f) {
				if (v == true) {
					commonAjaxGet(dellink, deldata);
				}
			},
			{buttons: {'是': true, '否': false}}
		);
		return false;
	});
});
</script>
</body>
</html>